﻿using Abs.Core.DAL;
using Abs.Core.DAL.AdoNet;
using Abs.Core.Models.Room;
using NUnit.Framework;

namespace Abs.Core.UnitTesting
{
    //[TestFixture]
    public class RoomRepository
    {
        private AdoNetRepository<Room> AdoNetRepository { get; set; }
        private Room Room { get; set; }

        //[TestFixtureSetUp]
        public void BeforeTests()
        {
            this.Room = new Room {RoomId = 7, Name = "Element"};
        }//end of public void BeforeTests()

        //[SetUp]
        public void BeforeEachTest()
        {
            this.AdoNetRepository = new DAL.AdoNet.RoomRepository();
        }//end of internal void BeforeEachTest()

        //[TearDown]
        public void AfterEachTest()
        {
            if (this.AdoNetRepository != null)
                this.AdoNetRepository.Dispose();
        }//end of internal void AfterEachTest()

        //[Test]
        public void CreateRoom()
        {
            this.Room.Name = "Element Room";
            var isSuccess = this.AdoNetRepository.Create(this.Room);
            Assert.True(isSuccess);
        }//end of public void CreateRoomSchedule()

        //[Test]
        public void EditRoom()
        {
            this.Room.Name = "Element Room";
            var isSuccess = this.AdoNetRepository.Update(this.Room);
            Assert.True(isSuccess);
        }//end of public void EditRoom()

        //[Test]
        public void GetRoom()
        {
            var id = new object[] {this.Room.RoomId};
            var room = this.AdoNetRepository.Select(id);
            Assert.NotNull(room);
        }//end of public void SelectRoom()

        //[Test]
        public void GetAllRoom()
        {
            var totalRooms = this.AdoNetRepository.SelectAll().Count;
            var expectedTotalRooms = 5;
            Assert.AreEqual(expectedTotalRooms, totalRooms);
        }//end of public void SelectAllRoom()

        //[Test]
        public void RemoveRoom()
        {
            var id = new object[] {this.Room.RoomId};
            var isSuccess = this.AdoNetRepository.Delete(id);
            Assert.True(isSuccess);
        }//end of public void RemoveRoom()
    }//end of public class RoomRepository
}//end of namespace ABS.UnitTesting